import request from '@/utils/request'

// 查询知识库列表
export function listKnowledge(query) {
  return request({
    url: '/api/knowledge/list',
    method: 'post',
    data: query,
    isQuery: true,
    timeout: 200000
  })
}

// 查询知识库详细
export function getKnowledge(id) {
  return request({
    url: '/api/knowledge/getDetail/' + id,
    method: 'get'
  })
}


export function initMilvus(param){
  return request({
    isLoading: true,
    url: '/api/knowledge/initMilvus' ,
    method: 'post',
    params: param,
    timeout: 60000
  })
}


export function addKnowledge(data) {
  return request({
    isLoading: true,
    url: '/api/knowledge/add',
    method: 'post',
    data: data
  })
}
// 修改
export function updateKnowledge(data) {
  return request({
    isLoading: true,
    url: '/api/knowledge/edit',
    method: 'put',
    data: data
  })
}

//删除
export function delKnowledge(ids) {
  return request({
    isLoading: true,
    url: '/api/knowledge/delete',
    method: 'delete',
    data: {
      ids: ids
    }
  })
}


// 查询知识库文件列表
export function listDocument(data) {
  return request({
    url: '/api/knowledge/doc/list',
    method: 'post',
    data: data,
    isQuery: true,
    timeout: 2000
  })
}


// 查询知识库详细
export function getDocument(id) {
  return request({
    url: '/api/knowledge/doc/getDetail/' + id,
    method: 'get'
  })
}
// 修改
export function updateDocument(data) {
  return request({
    isLoading: true,
    url: '/api/knowledge/doc/edit',
    method: 'put',
    data: data
  })
}

//向量化
export function processingDocument(ids) {
  return request({
    isLoading: true,
    url: '/api/knowledge/doc/processing',
    method: 'post',
    data: {
      ids: ids
    },
    timeout: 3600000
  })
}

//更新状态到草稿
export function changeDocumentStatusToDraft(data) {
  return request({
    isLoading: true,
    url: '/api/knowledge/doc/changeStatusToDraft',
    method: 'post',
    data: data
  })
}

//更新文件状态
export function changeDocumentStatus(data) {
  return request({
    isLoading: true,
    url: '/api/knowledge/doc/changeStatus',
    method: 'post',
    data: data
  })
}

//删除
export function delDocument(ids) {
  return request({
    isLoading: true,
    url: '/api/knowledge/doc/delete',
    method: 'delete',
    data: {
      ids: ids
    }
  })
}
